package org.starapp.rbac.entity;

import javax.persistence.GenerationType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Column;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.google.common.collect.ImmutableList;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author wangqiang@cisoft.com.cn
 *
 */
@Entity
@Table(name = "rbac_roles")
public class Roles implements Serializable{
		
				
		/**
		 * ROLE_ID
		 */
		private String roleId;
				
		/**
		 * ROLE_NAME
		 */
		private String roleName;
		
		/**
		 * Roles
		 */
		private Roles roles;
		


		private List<Users> usersM2MList;				
		
				
		@Id
		@Column(name="ROLE_ID")
		@NotBlank
		public String getRoleId(){
			return this.roleId;
		}
		
		public void setRoleId(String roleId){
			this.roleId = roleId;
		}
		
				
		@NotBlank
		public String getRoleName(){
			return this.roleName;
		}
		
		public void setRoleName(String roleName){
			this.roleName = roleName;
		}
		
		
				
		@ManyToMany
		@JoinTable(name = "rbac_roles_users", joinColumns={@JoinColumn(name="ROLE_ID") },inverseJoinColumns={@JoinColumn(name="USER_ID")})		
		public List<Users> getUsersM2MList(){
			return this.usersM2MList;
		}
		
		public void setUsersM2MList(List<Users> usersM2MList){
			this.usersM2MList = usersM2MList;
		}

		@OneToOne
		@JoinColumn(name = "PARENT_ROLE_ID")					
		public Roles getRoles(){
			return this.roles;
		}
		
		public void setRoles(Roles roles){
			this.roles = roles;
		}

		
		@Override
		public String toString() {
			return ToStringBuilder.reflectionToString(this);
		}
	
	}

